<%@page import="model.Model"%>
<%@page import="model.ModelImpl"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.List"%>
<%@page import="domain.Student"%>
<%@page pageEncoding="UTF-8" %>

<jsp:include page="/WEB-INF/jspf/lefter.jspf"/>

<div id="container">

    <h1>Список студентов</h1>
    <div style="background-color: coral; width: 400px " > ${requestScope['exception'].message}</div>
   

    <% 
        Exception ex = (Exception) request.getAttribute("exception");
        if(ex != null){         
            System.out.println("ex" + ex.getMessage()); 
            System.out.println("full_ex" + ex); 
        }
        List<Student> students = (List<Student>) request.getAttribute("students");

    %>

    <table border="1">
        <td>№</td>
        <td><fmt:message key='id'/></td>
        <td><fmt:message key='lastNameRu'/></td>
        <td><fmt:message key='firstNameRu'/></td>
        <td><fmt:message key='emailOffice'/></td>
        <td> <fmt:message key='dateOfBirth'/></td>
        <td>-</td>
        <td>-</td>
        <%
            int i = 1;
            for (Student st : students) {
                pageContext.setAttribute("std", st);
        %>

        <jsp:useBean id="std" class="domain.Student"/>
        <tr>

            <!--out.print(String.format("<td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>",-->
            <td><%=i++%></td>
            <td>${std.id}</td>
            <td>${std.lastNameRu}</td>
            <td>${std.firstNameRu}</td>
            <td>${std.emailOffice}</td>
            <td> <fmt:formatDate type="date" dateStyle="medium"  value="${std.dateOfBirth}" /></td>
            <td><a href="editStudent?action=edit&id=${std.id}">Изменить</a></td>
            <td><a href="deleteStudent?id=${std.id}">Удалить</a></td>
        </tr>

        <% }%>  



    </table>
</div>





